@include('common.header')


<div class="row" style="width:100%;margin-top:5%;" >
	<div class="col-md-6" style="text-align:center;" >
		<!-- 页面标记  -->
		<div style="margin:20px;margin-left:-5px;color:green;font-size:22px;">
		@if( isset($admin_info) )
			编辑管理员
		@else
			添加管理员
		@endif
		</div>
		
	</div>
	<div class="col-md-6">
	</div>
</div>


<div class="row" style="width:100%;margin:0 auto;" >
	<div class="col-md-2">
	</div>
	<div class="col-md-10">
		<!-- 账户 -->
		<div  class="form-group">
			<label class="col-sm-2 control-label">账号</label>
			<div class="col-sm-10">
				<input style="width:430px;" type="text" name="name" value="{{ $admin_info->name or '' }}" class="form-control username"  placeholder="账户" />
			</div>
		</div>
		
		<br/><br/>
		<!-- 密码 -->
		<div  class="form-group">
		  <label class="col-sm-2 control-label">密码</label>
		  <div class="col-sm-10">
			<input style="width:430px;" type="password" name="pass" value="{{ $admin_info->pass or '' }}" class="form-control pass"  placeholder="密码" />
		  </div>
		</div>
		
		<br/><br/>
		<!-- 确认密码 -->
		<div  class="form-group">
		  <label class="col-sm-2 control-label">确认密码</label>
		  <div class="col-sm-10">
			<input style="width:430px;" type="password" name="repass" value="{{ $admin_info->pass or '' }}" class="form-control repass"  placeholder="确认密码" />
		  </div>
		</div>

		<br/><br/><br/>
		
		<div style="overflow:hidden;width:450px;">
   
			<button  style="width:200px;float:left;" class="btn btn-danger">保存</button>
			<div style="margin-left:50px;float:left;margin-bottom:200px;">
				<a href="javascript:" onclick="self.location=document.referrer;"  style="width:200px;" class="btn btn-success">
				返回
				</a>
			</div>
			
		</div>
	</div>
</div>


<script type="text/javascript">
	
	//点击添加
	$(".btn-danger").click(function()
	{
		var name=$(".username").val();
		var pass = $(".pass").val();
		var repass = $(".repass").val();
		$.ajax({
			 type: "post",
			 url: "{{ url('/adminAdd') }}",
			 data: {
				name: name,
				pass: pass,
				repass: repass,
				admin_id:"{{ $admin_info->id or '' }}",
				_token: _token
			},
			async: false,
			dataType: "json",
			success: function (back) 
			{
				if( back['show_info'].indexOf("成功") > 0 )
				{
					$(".btn-danger").attr('disabled',true);
				}
				$(".opa").html(back['show_info']);
				$(".opa").slideDown(1000);
				$(".opa").delay(1500).slideUp(1000);
			}
		})
	})

</script>


@extends('common.footer')